﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Administrator/AdminMaster.Master" AutoEventWireup="true" CodeBehind="ManageSpecialists.aspx.cs" Inherits="MyHealthOnline.Administrator.ManageSpecialists" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
    <asp:UpdatePanel ID="updSpecialists" runat="server" ChildrenAsTriggers="true" UpdateMode="Conditional">
        <Triggers>
            <asp:AsyncPostBackTrigger ControlID="btnAddSpecialist" EventName="Click" />
            <asp:AsyncPostBackTrigger ControlID="grdSpecialists" EventName="RowCommand" />
            <asp:AsyncPostBackTrigger ControlID="grdSpecialists" EventName="RowUpdating" />
        </Triggers>
        <ContentTemplate>
            <asp:GridView id="grdSpecialists" runat="server" AllowPaging="True"  DataKeyNames="Id"
                AutoGenerateColumns="False" CellPadding="4" CssClass="grdExtraCols"
                DataSourceID="specsObjectDataSource" ForeColor="#333333" 
                GridLines="None" onrowcommand="grdSpecialists_RowCommand" 
                onrowupdating="grdSpecialists_RowUpdating">
                <AlternatingRowStyle BackColor="White" />
                <Columns>
                    <asp:TemplateField ShowHeader="False">
                        <EditItemTemplate>
                            <asp:LinkButton ID="LinkButton1" runat="server" CausesValidation="false" 
                                 CommandArgument="<%# Container.DataItemIndex %>"
                                CommandName="Update" Text="Update"></asp:LinkButton>
                            &nbsp;<asp:LinkButton ID="LinkButton2" runat="server" CausesValidation="False" 
                                 CommandArgument="<%# Container.DataItemIndex %>"
                                CommandName="Cancel" Text="Cancel"></asp:LinkButton>
                        </EditItemTemplate>
                        <ItemTemplate>
                            <asp:LinkButton ID="LinkButton1" runat="server" CausesValidation="False" 
                                 CommandArgument="<%# Container.DataItemIndex %>"
                                CommandName="Edit" Text="Edit"></asp:LinkButton>
                        </ItemTemplate>
                    </asp:TemplateField>
                    <asp:CommandField ShowDeleteButton="True"></asp:CommandField>
                    <asp:TemplateField HeaderText="Id" SortExpression="Id">
                        <EditItemTemplate>
                            <div class="footerText">
                                <asp:TextBox ID="txtId" runat="server" Text='<%# Bind("Id") %>'></asp:TextBox>
                            </div>
                        </EditItemTemplate>
                        <ItemTemplate>
                            <asp:Label ID="Label1" runat="server" Text='<%# Bind("Id") %>'></asp:Label>
                        </ItemTemplate>
                    </asp:TemplateField>
                    <asp:TemplateField HeaderText="Name" SortExpression="Name">
                        <EditItemTemplate>
                            <div class="footerText">
                                <asp:TextBox ID="txtName" runat="server" Text='<%# Bind("Name") %>'></asp:TextBox>
                            </div>
                        </EditItemTemplate>
                        <ItemTemplate>
                            <asp:Label ID="Label2" runat="server" Text='<%# Bind("Name") %>'></asp:Label>
                        </ItemTemplate>
                    </asp:TemplateField>
                    <asp:TemplateField HeaderText="Address" SortExpression="Address">
                        <EditItemTemplate>
                            <div class="footerText">
                                <asp:TextBox ID="txtAddress" runat="server" Text='<%# Bind("Address") %>'></asp:TextBox>
                            </div>
                        </EditItemTemplate>
                        <ItemTemplate>
                            <asp:Label ID="Label3" runat="server" Text='<%# Bind("Address") %>'></asp:Label>
                        </ItemTemplate>
                    </asp:TemplateField>
                    <asp:TemplateField HeaderText="City" SortExpression="City">
                        <EditItemTemplate>
                            <div class="footerText">
                                <asp:TextBox ID="txtCity" runat="server" Text='<%# Bind("City") %>'></asp:TextBox>
                            </div>
                        </EditItemTemplate>
                        <ItemTemplate>
                            <asp:Label ID="Label4" runat="server" Text='<%# Bind("City") %>'></asp:Label>
                        </ItemTemplate>
                    </asp:TemplateField>
                    <asp:TemplateField HeaderText="Country" SortExpression="Country">
                        <EditItemTemplate>
                            <div class="footerText">
                                <asp:TextBox ID="txtCountry" runat="server" Text='<%# Bind("Country") %>'></asp:TextBox>
                            </div>
                        </EditItemTemplate>
                        <ItemTemplate>
                            <asp:Label ID="Label5" runat="server" Text='<%# Bind("Country") %>'></asp:Label>
                        </ItemTemplate>
                    </asp:TemplateField>
                    <asp:TemplateField HeaderText="Birthday" SortExpression="Birthday">
                        <EditItemTemplate>
                            <div class="footerText">
                                <asp:TextBox ID="txtBirthday" runat="server" Text='<%# Bind("Birthday") %>'></asp:TextBox>
                            </div>
                        </EditItemTemplate>
                        <ItemTemplate>
                            <asp:Label ID="Label6" runat="server" Text='<%# Bind("Birthday") %>'></asp:Label>
                        </ItemTemplate>
                    </asp:TemplateField>
                    <asp:TemplateField HeaderText="Discipline" SortExpression="DisciplineId">
                        <EditItemTemplate>
                            <div class="footerText">
                                <asp:DropDownList ID="ddlDisciplines" runat="server" Text='<%# Bind("DisciplineId") %>'
                                    DataSourceID="discDS" DataTextField="Title" DataValueField="Id"></asp:DropDownList>
                            </div>
                        </EditItemTemplate>
                        <ItemTemplate>
                            <asp:Label ID="Label7" runat="server" Text='<%# Bind("Title") %>'></asp:Label>
                        </ItemTemplate>
                    </asp:TemplateField>
                    <asp:TemplateField HeaderText="Email" SortExpression="Email">
                        <EditItemTemplate>
                            <div class="footerText">
                                <asp:TextBox ID="txtEmail" runat="server" Text='<%# Bind("Email") %>'></asp:TextBox>
                            </div>
                        </EditItemTemplate>
                        <ItemTemplate>
                            <asp:Label ID="Label8" runat="server" Text='<%# Bind("Email") %>'></asp:Label>
                        </ItemTemplate>
                    </asp:TemplateField>
                    <asp:TemplateField HeaderText="Organization" SortExpression="Organization">
                        <EditItemTemplate>
                            <div class="footerText">
                                <asp:TextBox ID="txtOrganization" runat="server" Text='<%# Bind("Organization") %>'></asp:TextBox>
                            </div>
                        </EditItemTemplate>
                        <ItemTemplate>
                            <asp:Label ID="Label9" runat="server" Text='<%# Bind("Organization") %>'></asp:Label>
                        </ItemTemplate>
                    </asp:TemplateField>
                    <asp:TemplateField HeaderText="Password" SortExpression="Password">
                        <EditItemTemplate>
                            <div class="footerText">
                                <asp:TextBox ID="txtPassword" TextMode="Password" runat="server" Text='<%# Bind("Password") %>'></asp:TextBox>
                            </div>
                        </EditItemTemplate>
                        <ItemTemplate>
                            <asp:Label ID="Label10" runat="server" Text='<%# Bind("Password") %>'></asp:Label>
                        </ItemTemplate>
                    </asp:TemplateField>
                    <asp:TemplateField HeaderText="Phone" SortExpression="Phone">
                        <EditItemTemplate>
                            <div class="footerText">
                                <asp:TextBox ID="txtPhone" runat="server" Text='<%# Bind("Phone") %>'></asp:TextBox>
                            </div>
                        </EditItemTemplate>
                        <ItemTemplate>
                            <asp:Label ID="label11" runat="server" Text='<%# Bind("Phone") %>'></asp:Label>
                        </ItemTemplate>
                    </asp:TemplateField>
                    <asp:TemplateField HeaderText="Sex" SortExpression="Sex">
                        <EditItemTemplate>
                            <div class="footerText">
                                <asp:TextBox ID="txtSex" runat="server" Text='<%# Bind("Sex") %>'></asp:TextBox>
                            </div>
                        </EditItemTemplate>
                        <ItemTemplate>
                            <asp:Label ID="Label12" runat="server" Text='<%# Bind("Sex") %>'></asp:Label>
                        </ItemTemplate>
                    </asp:TemplateField>
                </Columns>
                <EditRowStyle BackColor="#7C6F57" />
                <FooterStyle BackColor="#1C5E55" Font-Bold="True" ForeColor="White" />
                <HeaderStyle BackColor="#1C5E55" Font-Bold="True" ForeColor="White" />
                <PagerStyle BackColor="#666666" ForeColor="White" HorizontalAlign="Center" />
                <RowStyle BackColor="#E3EAEB" />
                <SelectedRowStyle BackColor="#C5BBAF" Font-Bold="True" ForeColor="#333333" />
                <sortedascendingcellstyle backcolor="#F8FAFA" />
                <sortedascendingheaderstyle backcolor="#246B61" />
                <sorteddescendingcellstyle backcolor="#D4DFE1" />
                <sorteddescendingheaderstyle backcolor="#15524A" />
                <sortedascendingcellstyle backcolor="#F8FAFA" />
                <sortedascendingheaderstyle backcolor="#246B61" />
                <sorteddescendingcellstyle backcolor="#D4DFE1" />
                <sorteddescendingheaderstyle backcolor="#15524A" />
                <sortedascendingcellstyle backcolor="#F8FAFA" />
                <sortedascendingheaderstyle backcolor="#246B61" />
                <sorteddescendingcellstyle backcolor="#D4DFE1" />
                <sorteddescendingheaderstyle backcolor="#15524A" />
                <sortedascendingcellstyle backcolor="#F8FAFA" />
                <sortedascendingheaderstyle backcolor="#246B61" />
                <sorteddescendingcellstyle backcolor="#D4DFE1" />
                <sorteddescendingheaderstyle backcolor="#15524A" />
                <sortedascendingcellstyle backcolor="#F8FAFA" />
                <sortedascendingheaderstyle backcolor="#246B61" />
                <sorteddescendingcellstyle backcolor="#D4DFE1" />
                <sorteddescendingheaderstyle backcolor="#15524A" />
                <sortedascendingcellstyle backcolor="#F8FAFA" />
                <sortedascendingheaderstyle backcolor="#246B61" />
                <sorteddescendingcellstyle backcolor="#D4DFE1" />
                <sorteddescendingheaderstyle backcolor="#15524A" />
                <sortedascendingcellstyle backcolor="#F8FAFA" />
                <sortedascendingheaderstyle backcolor="#246B61" />
                <sorteddescendingcellstyle backcolor="#D4DFE1" />
                <sorteddescendingheaderstyle backcolor="#15524A" />
                <sortedascendingcellstyle backcolor="#F8FAFA" />
                <sortedascendingheaderstyle backcolor="#246B61" />
                <sorteddescendingcellstyle backcolor="#D4DFE1" />
                <sorteddescendingheaderstyle backcolor="#15524A" />
                <sortedascendingcellstyle backcolor="#F8FAFA" />
                <sortedascendingheaderstyle backcolor="#246B61" />
                <sorteddescendingcellstyle backcolor="#D4DFE1" />
                <sorteddescendingheaderstyle backcolor="#15524A" />
            </asp:GridView>
            <asp:ObjectDataSource ID="specsObjectDataSource" runat="server" 
                SelectMethod="GetSpecialists" 
                TypeName="MyHealthOnline.Business.SpecialistBusiness" 
                DeleteMethod="DeleteSpecialist" InsertMethod="CreateSpecialist" 
                UpdateMethod="UpdateSpecialist">
                <DeleteParameters>
                    <asp:Parameter Name="specId" Type="String" />
                </DeleteParameters>
                <InsertParameters>
                    <asp:Parameter Name="name" Type="String" />
                    <asp:Parameter Name="password" Type="String" />
                    <asp:Parameter Name="code" Type="String" />
                    <asp:Parameter Name="organization" Type="String" />
                    <asp:Parameter Name="discipline" Type="String" />
                    <asp:Parameter Name="email" Type="String" />
                    <asp:Parameter Name="address" Type="String" />
                    <asp:Parameter Name="city" Type="String" />
                    <asp:Parameter Name="country" Type="String" />
                    <asp:Parameter Name="phone" Type="String" />
                    <asp:Parameter Name="birthday" Type="String" />
                    <asp:Parameter Name="gender" Type="String" />
                </InsertParameters>
                <UpdateParameters>
                    <asp:Parameter Name="id" Type="String" />
                    <asp:Parameter Name="name" Type="String" />
                    <asp:Parameter Name="password" Type="String" />
                    <asp:Parameter Name="organization" Type="String" />
                    <asp:Parameter Name="discipline" Type="String" />
                    <asp:Parameter Name="email" Type="String" />
                    <asp:Parameter Name="address" Type="String" />
                    <asp:Parameter Name="city" Type="String" />
                    <asp:Parameter Name="country" Type="String" />
                    <asp:Parameter Name="phone" Type="String" />
                    <asp:Parameter Name="birthday" Type="String" />
                    <asp:Parameter Name="sex" Type="String" />
                    <asp:Parameter Name="disciplineId" Type="Int32" />
                </UpdateParameters>
            </asp:ObjectDataSource>
            <br />
            <table>
                <tr>
                    <td>Name</td>
                    <td>
                        <asp:Textbox id="txtNewName" runat="server" Text=""></asp:Textbox>
                    </td>
                </tr>
                <tr>
                    <td>Password</td>
                    <td>
                        <asp:Textbox id="txtNewPassword" runat="server" Text=""></asp:Textbox>
                    </td>
                </tr>
                <tr>
                    <td>Code</td>
                    <td>
                        <asp:Textbox id="txtNewCode" runat="server" Text=""></asp:Textbox>
                    </td>
                </tr>
                <tr>
                    <td>Organization</td>
                    <td>
                        <asp:Textbox id="txtNewOrganization" runat="server" Text=""></asp:Textbox>
                    </td>
                </tr>
                <tr>
                    <td>Discipline></td>
                    <td>
                        <asp:DropDownList id="ddlNewDisciplines" runat="server" DataSourceID="discDS" 
                            DataTextField="Title" DataValueField="Id" ></asp:DropDownList>
                    </td>
                </tr>
                <tr>
                    <td>Email</td>
                    <td>
                        <asp:Textbox id="txtNewEmail" runat="server" Text=""></asp:Textbox>
                    </td>
                </tr>
                <tr>
                    <td>Address</td>
                    <td>
                        <asp:Textbox id="txtNewAddress" runat="server" Text=""></asp:Textbox>
                    </td>
                </tr>
                <tr>
                    <td>City</td>
                    <td>
                        <asp:Textbox id="txtNewCity" runat="server" Text=""></asp:Textbox>
                    </td>
                </tr>
                <tr>
                    <td>Country</td>
                    <td>
                        <asp:Textbox id="txtNewCountry" runat="server" Text=""></asp:Textbox>
                    </td>
                </tr>
                <tr>
                    <td>Phone</td>
                    <td>
                        <asp:Textbox id="txtNewPhone" runat="server" Text=""></asp:Textbox>
                    </td>
                </tr>
                <tr>
                    <td>Birthday</td>
                    <td>
                        <asp:Textbox id="txtNewBirthday" runat="server" Text=""></asp:Textbox>
                    </td>
                </tr>
                <tr>
                    <td>Sex</td>
                    <td>
                        <asp:RadioButtonList ID="rblGender" runat="server" RepeatDirection="Horizontal">
                            <asp:ListItem Text="Male" Value="Male" Selected="true"></asp:ListItem>
                            <asp:ListItem Text="Female" Value="Female"></asp:ListItem>
                        </asp:RadioButtonList>
                    </td>
                </tr>
            </table>
            
            <br />
            <asp:ObjectDataSource id="discDS" runat="server" SelectMethod="GetDisciplines" 
                TypeName="MyHealthOnline.Business.DisciplineBusiness"></asp:ObjectDataSource>
            <asp:Button id="btnAddSpecialist" runat="server" Text="Add" onclick="btnAdd_Click" />
        </ContentTemplate>
    </asp:UpdatePanel>
</asp:Content>
